package com.tianheng.wanzhou.datacollecting.netty.kongyajiR150.receiver.receiverImpl;

import com.baomidou.mybatisplus.extension.service.IService;
import com.tianheng.wanzhou.datacollecting.DataCollectingApplication;
import com.tianheng.wanzhou.datacollecting.db.entity.AirCompressorAmpsHis;
import com.tianheng.wanzhou.datacollecting.db.entity.AirCompressorPowerHis;
import com.tianheng.wanzhou.datacollecting.db.entity.AirCompressorR1503;
import com.tianheng.wanzhou.datacollecting.db.service.IAirCompressorAmpsHisService;
import com.tianheng.wanzhou.datacollecting.db.service.IAirCompressorPowerHisService;
import com.tianheng.wanzhou.datacollecting.db.service.IAirCompressorR1503Service;
import com.tianheng.wanzhou.datacollecting.netty.kongyajiR150.receiver.Receiver;
import com.tianheng.wanzhou.datacollecting.util.FloatOperate;
import com.tianheng.wanzhou.datacollecting.util.StrUtil;
import com.tianheng.wanzhou.datacollecting.util.TqlHexchange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author: yujw
 * @Date: 2020/5/21 8:38
 * @Version 1.0
 */
@Component("r150A3")
public class Air3Receiver extends Receiver {

    @Autowired
    IAirCompressorR1503Service service;

//    @Autowired
//    IAirCompressorAmpsHisService ampsHisService;
//
//    @Autowired
//    IAirCompressorPowerHisService powerHisService;

    @Override
    public Object parseMessage(String message, String ip, Integer company, Integer workshop, String machineId) {
        String code = message.substring(4, 6);
        String data = message.substring(6, message.length() - 4);
        String hex = null;
        String binary = null;
        char[] binaries = null;
        AirCompressorR1503 airCompressorR1503 = new AirCompressorR1503();
        airCompressorR1503.setMachineIp(ip);
        airCompressorR1503.setCompany(company);
        airCompressorR1503.setWorkshop(workshop);
        airCompressorR1503.setMachineId(machineId);
//        if(code.equals("92")){
//            airCompressorR1503.setSystemPressure((FloatOperate.operate(data.substring(0, 8)).toDouble())/14.2698);
//            airCompressorR1503.setDischargePressure((FloatOperate.operate(data.substring(8, 16)).toDouble())/14.2698);
//            airCompressorR1503.setOilPressure((FloatOperate.operate(data.substring(16, 24)).toDouble())/14.2698);
//            airCompressorR1503.setMotorAmps(FloatOperate.operate(data.substring(24, 32)).toDouble());
//            airCompressorR1503.setLowSpeedVibration(FloatOperate.operate(data.substring(32, 40)).toDouble());
//            airCompressorR1503.setHighSpeedVibration(FloatOperate.operate(data.substring(40, 48)).toDouble());
//            airCompressorR1503.setInletOilTemperature(FloatOperate.operate(data.substring(48, 56)).toDouble());
//            airCompressorR1503.setFinalInterstageAirTemperature(FloatOperate.operate(data.substring(56, 64)).toDouble());
//            airCompressorR1503.setAftercoolerAirTempdrature(FloatOperate.operate(data.substring(64, 72)).toDouble());
//            airCompressorR1503.setFirstStageDischargeTemperature(FloatOperate.operate(data.substring(72, 80)).toDouble());
//            airCompressorR1503.setFirstStageDischargePressure(FloatOperate.operate(data.substring(80, 88)).toDouble());
//            airCompressorR1503.setSecondStageDischargeTemperature(FloatOperate.operate(data.substring(88, 96)).toDouble());
//            airCompressorR1503.setMotorStatorTemperature(FloatOperate.operate(data.substring(96, 104)).toDouble());
//            airCompressorR1503.setInboardMotorBearingTemperature(FloatOperate.operate(data.substring(104, 112)).toDouble());
//            airCompressorR1503.setOutboardMotorBearingTemperature(FloatOperate.operate(data.substring(112, 120)).toDouble());
//            airCompressorR1503.setAi15(FloatOperate.operate(data.substring(120, 128)).toDouble());
//            airCompressorR1503.setInletValve(FloatOperate.operate(data.substring(128, 136)).toDouble());
//            airCompressorR1503.setUnloadingValve(FloatOperate.operate(data.substring(136, 144)).toDouble());
//            airCompressorR1503.setInletValveManualMode(FloatOperate.operate(data.substring(144, 152)).toDouble());
//            airCompressorR1503.setUnloadingValveManualMode(FloatOperate.operate(data.substring(152, 160)).toDouble());
//            hex = data.substring(288, 292);
//            binary = StrUtil.hexStr2BinaryStr(hex);
//            binaries = binary.toCharArray();
//            airCompressorR1503.setMotorMContactor(Character.digit(binaries[0], 2));
//            airCompressorR1503.setAuxOilPump(Character.digit(binaries[1], 2));
//            airCompressorR1503.setCoolingWater(Character.digit(binaries[2], 2));
//            airCompressorR1503.setCommonAlarmRelay(Character.digit(binaries[3], 2));
//            airCompressorR1503.setCommonTripRelay(Character.digit(binaries[4], 2));
//            airCompressorR1503.setHorn(Character.digit(binaries[5], 2));
//            airCompressorR1503.setAlarmLight(Character.digit(binaries[6], 2));
//            airCompressorR1503.setTripLight(Character.digit(binaries[7], 2));
//            airCompressorR1503.setEmergencyStop(Character.digit(binaries[8], 2));
//            airCompressorR1503.setLowOilLevel(Character.digit(binaries[9], 2));
//            airCompressorR1503.setSealAirPressure(Character.digit(binaries[10], 2));
//            airCompressorR1503.setRemoteStart(Character.digit(binaries[11], 2));
//            airCompressorR1503.setRemoteStop(Character.digit(binaries[12], 2));
//            airCompressorR1503.setRemoteUnload(Character.digit(binaries[13], 2));
//            airCompressorR1503.setOilFilterDifPressure(Character.digit(binaries[14], 2));
//            airCompressorR1503.setAirFilterDifPressure(Character.digit(binaries[15], 2));
//
//        }
//        if(code.equals("22")){
//            hex = data.substring(0, 4);
//            binary = StrUtil.hexStr2BinaryStr(hex);
//            binaries = binary.toCharArray();
//            airCompressorR1503.setAirFilterServiceAlarm(Character.digit(binaries[0], 2));
//            airCompressorR1503.setOilFilterServiceAlarm(Character.digit(binaries[1], 2));
//            airCompressorR1503.setOilSampleServiceAlarm(Character.digit(binaries[2], 2));
//            airCompressorR1503.setLubricantServiceAlarm(Character.digit(binaries[3], 2));
//            airCompressorR1503.setGreaseServiceAlarm(Character.digit(binaries[4], 2));
//            airCompressorR1503.setOilMistEliminatorServiceAlarm(Character.digit(binaries[5], 2));
//            airCompressorR1503.setCleanCoolerServiceAlarm(Character.digit(binaries[6], 2));
//            airCompressorR1503.setCleanAeroHardwareServiceAlarm(Character.digit(binaries[7], 2));
//            airCompressorR1503.setAirEndInspectionServiceAlarm(Character.digit(binaries[8], 2));
//            airCompressorR1503.setDriverOverhaulServiceAlarm(Character.digit(binaries[9], 2));
//        }
//        if(code.equals("56")){
//            airCompressorR1503.setD41301(StrUtil.hexStr2Int(data.substring(0, 4)));
//            airCompressorR1503.setD41322(StrUtil.hexStr2Int(data.substring(84, 88)));
//            airCompressorR1503.setD41343(StrUtil.hexStr2Int(data.substring(168, 172)));
//        }
//        if(code.equals("34")){
//            char[] binaries1 = StrUtil.hexStr2BinaryStr(data.substring(0, 4)).toCharArray();
//            char[] binaries2 = StrUtil.hexStr2BinaryStr(data.substring(4, 8)).toCharArray();
//            char[] binaries3 = StrUtil.hexStr2BinaryStr(data.substring(8, 12)).toCharArray();
//            char[] binaries4 = StrUtil.hexStr2BinaryStr(data.substring(12, 16)).toCharArray();
//            char[] binaries5 = StrUtil.hexStr2BinaryStr(data.substring(16, 20)).toCharArray();
//            char[] binaries6 = StrUtil.hexStr2BinaryStr(data.substring(20, 24)).toCharArray();
//            char[] binaries7 = StrUtil.hexStr2BinaryStr(data.substring(24, 28)).toCharArray();
//            char[] binaries8 = StrUtil.hexStr2BinaryStr(data.substring(28, 32)).toCharArray();
//            char[] binaries9 = StrUtil.hexStr2BinaryStr(data.substring(32, 36)).toCharArray();
//            char[] binaries10 = StrUtil.hexStr2BinaryStr(data.substring(36, 40)).toCharArray();
//            airCompressorR1503.setSptFailTrip(Character.digit(binaries1[0], 2));
//            airCompressorR1503.setSptLowAlarm(Character.digit(binaries1[1], 2));
//            airCompressorR1503.setSdtHighAlarm(Character.digit(binaries1[2], 2));
//            airCompressorR1503.setSdtLowTrip(Character.digit(binaries1[3], 2));
//            airCompressorR1503.setSdtHighTrip(Character.digit(binaries1[4], 2));
//            airCompressorR1503.setSdtBypassed(Character.digit(binaries1[5], 2));
//            airCompressorR1503.setSptFailAlarm(Character.digit(binaries1[6], 2));
//            airCompressorR1503.setDptFail(Character.digit(binaries1[8], 2));
//            airCompressorR1503.setDptLowAlarm(Character.digit(binaries1[9], 2));
//            airCompressorR1503.setDptHighAlarm(Character.digit(binaries1[10], 2));
//            airCompressorR1503.setDptLowTrip(Character.digit(binaries1[11], 2));
//            airCompressorR1503.setDptHighTrip(Character.digit(binaries1[12], 2));
//            airCompressorR1503.setDptBypassed(Character.digit(binaries1[13], 2));
//
//            airCompressorR1503.setOptFail(Character.digit(binaries2[0], 2));
//            airCompressorR1503.setOptLowAlarm(Character.digit(binaries2[1], 2));
//            airCompressorR1503.setOptHighAlarm(Character.digit(binaries2[2], 2));
//            airCompressorR1503.setOptLowTrip(Character.digit(binaries2[3], 2));
//            airCompressorR1503.setOptHighTrip(Character.digit(binaries2[4], 2));
//            airCompressorR1503.setOptBypassed(Character.digit(binaries2[5], 2));
//            airCompressorR1503.setMatFail(Character.digit(binaries2[8], 2));
//            airCompressorR1503.setMatLowAlarm(Character.digit(binaries2[9], 2));
//            airCompressorR1503.setMatHighAlarm(Character.digit(binaries2[10], 2));
//            airCompressorR1503.setMatLowTrip(Character.digit(binaries2[11], 2));
//            airCompressorR1503.setMatHighTrip(Character.digit(binaries2[12], 2));
//            airCompressorR1503.setMatBypassed(Character.digit(binaries2[13], 2));
//
//            airCompressorR1503.setLvtFail(Character.digit(binaries3[0], 2));
//            airCompressorR1503.setLvtLowAlarm(Character.digit(binaries3[1], 2));
//            airCompressorR1503.setLvtHighAlarm(Character.digit(binaries3[2], 2));
//            airCompressorR1503.setLvtLowTrip(Character.digit(binaries3[3], 2));
//            airCompressorR1503.setLvtHighTrip(Character.digit(binaries3[4], 2));
//            airCompressorR1503.setLvtBypassed(Character.digit(binaries3[5], 2));
//            airCompressorR1503.setHvtFail(Character.digit(binaries3[8], 2));
//            airCompressorR1503.setHvtLowAlarm(Character.digit(binaries3[9], 2));
//            airCompressorR1503.setHvtHighAlarm(Character.digit(binaries3[10], 2));
//            airCompressorR1503.setHvtLowTrip(Character.digit(binaries3[11], 2));
//            airCompressorR1503.setHvtHighTrip(Character.digit(binaries3[12], 2));
//            airCompressorR1503.setHvtBypassed(Character.digit(binaries3[13], 2));
//
//            airCompressorR1503.setIotFail(Character.digit(binaries4[0], 2));
//            airCompressorR1503.setIotLowAlarm(Character.digit(binaries4[1], 2));
//            airCompressorR1503.setIotHighAlarm(Character.digit(binaries4[2], 2));
//            airCompressorR1503.setIotLowTrip(Character.digit(binaries4[3], 2));
//            airCompressorR1503.setIotHighTrip(Character.digit(binaries4[4], 2));
//            airCompressorR1503.setIotBypassed(Character.digit(binaries4[5], 2));
//            airCompressorR1503.setIatFail(Character.digit(binaries4[8], 2));
//            airCompressorR1503.setIatLowAlarm(Character.digit(binaries4[9], 2));
//            airCompressorR1503.setIatHighAlarm(Character.digit(binaries4[10], 2));
//            airCompressorR1503.setIatLowTrip(Character.digit(binaries4[11], 2));
//            airCompressorR1503.setIatHighTrip(Character.digit(binaries4[12], 2));
//            airCompressorR1503.setIatBypassed(Character.digit(binaries4[13], 2));
//
//            airCompressorR1503.setActFail(Character.digit(binaries5[0], 2));
//            airCompressorR1503.setActLowAlarm(Character.digit(binaries5[1], 2));
//            airCompressorR1503.setActHighAlarm(Character.digit(binaries5[2], 2));
//            airCompressorR1503.setActLowTrip(Character.digit(binaries5[3], 2));
//            airCompressorR1503.setActHighTrip(Character.digit(binaries5[4], 2));
//            airCompressorR1503.setActBypassed(Character.digit(binaries5[5], 2));
//            airCompressorR1503.setFitFail(Character.digit(binaries5[8], 2));
//            airCompressorR1503.setFitLowAlarm(Character.digit(binaries5[9], 2));
//            airCompressorR1503.setFitHighAlarm(Character.digit(binaries5[10], 2));
//            airCompressorR1503.setFitLowTrip(Character.digit(binaries5[11], 2));
//            airCompressorR1503.setFitHighTrip(Character.digit(binaries5[12], 2));
//            airCompressorR1503.setFitBypassed(Character.digit(binaries5[13], 2));
//
//            airCompressorR1503.setFdtFail(Character.digit(binaries6[0], 2));
//            airCompressorR1503.setFdtLowAlarm(Character.digit(binaries6[1], 2));
//            airCompressorR1503.setFdtHighAlarm(Character.digit(binaries6[2], 2));
//            airCompressorR1503.setFdtLowTrip(Character.digit(binaries6[3], 2));
//            airCompressorR1503.setFdtHighTrip(Character.digit(binaries6[4], 2));
//            airCompressorR1503.setFdtBypassed(Character.digit(binaries6[5], 2));
//            airCompressorR1503.setSdtFail(Character.digit(binaries6[8], 2));
//            airCompressorR1503.setSdtLowAlarm(Character.digit(binaries6[9], 2));
//            airCompressorR1503.setSdtHighAlarm(Character.digit(binaries6[10], 2));
//            airCompressorR1503.setSdtLowTrip(Character.digit(binaries6[11], 2));
//            airCompressorR1503.setSdtHighTrip(Character.digit(binaries6[12], 2));
//            airCompressorR1503.setSdtBypassed(Character.digit(binaries6[13], 2));
//
//            airCompressorR1503.setSmtFail(Character.digit(binaries7[0], 2));
//            airCompressorR1503.setSmtLowAlarm(Character.digit(binaries7[1], 2));
//            airCompressorR1503.setSmtHighAlarm(Character.digit(binaries7[2], 2));
//            airCompressorR1503.setSmtLowTrip(Character.digit(binaries7[3], 2));
//            airCompressorR1503.setSmtHighTrip(Character.digit(binaries7[4], 2));
//            airCompressorR1503.setSmtBypassed(Character.digit(binaries7[5], 2));
//            airCompressorR1503.setImtFail(Character.digit(binaries7[8], 2));
//            airCompressorR1503.setImtLowAlarm(Character.digit(binaries7[9], 2));
//            airCompressorR1503.setImtHighAlarm(Character.digit(binaries7[10], 2));
//            airCompressorR1503.setImtLowTrip(Character.digit(binaries7[11], 2));
//            airCompressorR1503.setImtHighTrip(Character.digit(binaries7[12], 2));
//            airCompressorR1503.setImtBypassed(Character.digit(binaries7[13], 2));
//
//            airCompressorR1503.setOmtFail(Character.digit(binaries8[0], 2));
//            airCompressorR1503.setOmtLowAlarm(Character.digit(binaries8[1], 2));
//            airCompressorR1503.setOmtHighAlarm(Character.digit(binaries8[2], 2));
//            airCompressorR1503.setOmtLowTrip(Character.digit(binaries8[3], 2));
//            airCompressorR1503.setOmtHighTrip(Character.digit(binaries8[4], 2));
//            airCompressorR1503.setOmtBypassed(Character.digit(binaries8[5], 2));
//            airCompressorR1503.setHvt2Fail(Character.digit(binaries8[8], 2));
//            airCompressorR1503.setHvt2LowAlarm(Character.digit(binaries8[9], 2));
//            airCompressorR1503.setHvt2HighAlarm(Character.digit(binaries8[10], 2));
//            airCompressorR1503.setHvt2LowTrip(Character.digit(binaries8[11], 2));
//            airCompressorR1503.setHvt2HighTrip(Character.digit(binaries8[12], 2));
//            airCompressorR1503.setHvt2Bypassed(Character.digit(binaries8[13], 2));
//
//            airCompressorR1503.setEstopTrip(Character.digit(binaries9[0], 2));
//            airCompressorR1503.setMotorFailureTrip(Character.digit(binaries9[1], 2));
//            airCompressorR1503.setOilPumpTrip(Character.digit(binaries9[2], 2));
//            airCompressorR1503.setCondenstateLevelTrip(Character.digit(binaries9[4], 2));
//
//            airCompressorR1503.setSurgeAlarm(Character.digit(binaries10[0], 2));
//            airCompressorR1503.setSapsAlarm(Character.digit(binaries10[1], 2));
//            airCompressorR1503.setLolsAlrm(Character.digit(binaries10[2], 2));
//            airCompressorR1503.setOfdpAlarm(Character.digit(binaries10[3], 2));
//            airCompressorR1503.setAfdpAlarm(Character.digit(binaries10[4], 2));
//            airCompressorR1503.setChannelBypassedAlarm(Character.digit(binaries10[5], 2));
//            airCompressorR1503.setCondensationLevelAlarm(Character.digit(binaries10[6], 2));
//            airCompressorR1503.setServiceAlarm(Character.digit(binaries10[7], 2));
//        }
//        if(code.equals("36")){
//            airCompressorR1503.setRuntime(TqlHexchange.fz8Int(data.substring(0,8)));
//            airCompressorR1503.setNumberOfStarts(StrUtil.hexStr2Int(data.substring(8, 16)));
//            airCompressorR1503.setNumberOfSurges(StrUtil.hexStr2Int(data.substring(16, 24)));
//            airCompressorR1503.setPoweronTime(StrUtil.hexStr2Int(data.substring(24, 32)));
//        }
//        if(code.equals("4E")){
//            airCompressorR1503.setAirFilterServiceTime(StrUtil.hexStr2Int(data.substring(0, 8)));
//            airCompressorR1503.setOilFilterServiceTime(StrUtil.hexStr2Int(data.substring(8, 16)));
//            airCompressorR1503.setOilSampleServiceTime(StrUtil.hexStr2Int(data.substring(16, 24)));
//            airCompressorR1503.setLubricantServiceTime(StrUtil.hexStr2Int(data.substring(24, 32)));
//            airCompressorR1503.setGreaseServiceTime(StrUtil.hexStr2Int(data.substring(32, 40)));
//            airCompressorR1503.setOilMistEliminatorServiceTime(StrUtil.hexStr2Int(data.substring(40, 48)));
//            airCompressorR1503.setCleanCoolerServiceTime(StrUtil.hexStr2Int(data.substring(48, 56)));
//            airCompressorR1503.setCleanAeroHardwareServiceTime(StrUtil.hexStr2Int(data.substring(56, 64)));
//            airCompressorR1503.setAirEndInspectionServiceTime(StrUtil.hexStr2Int(data.substring(64, 72)));
//            airCompressorR1503.setDriverOverhaulServiceTime(StrUtil.hexStr2Int(data.substring(72, 80)));
//        }
        switch (code) {
            //单字节屏幕数据
            case "04":
                airCompressorR1503.setSystemPressure(FloatOperate.operate(data.substring(0, 8)).toDouble());
                break;
            case "06":
                airCompressorR1503.setDischargePressure(FloatOperate.operate(data.substring(0, 8)).toDouble());
                break;
            case "08":
                airCompressorR1503.setOilPressure(FloatOperate.operate(data.substring(0, 8)).toDouble());
                break;
            case "0A":
                airCompressorR1503.setMotorAmps(FloatOperate.operate(data.substring(0, 8)).toDouble());
                break;
            case "0C":
                airCompressorR1503.setLowSpeedVibration(FloatOperate.operate(data.substring(0, 8)).toDouble());
                break;
            case "0E":
                airCompressorR1503.setHighSpeedVibration(FloatOperate.operate(data.substring(0, 8)).toDouble());
                break;
            case "10":
                airCompressorR1503.setInletOilTemperature(FloatOperate.operate(data.substring(0, 8)).toDouble());
                break;
            case "12":
                airCompressorR1503.setFinalInterstageAirTemperature(FloatOperate.operate(data.substring(0, 8)).toDouble());
                break;

            case "1C":
                airCompressorR1503.setFirstStageDischargeTemperature(FloatOperate.operate(data.substring(0, 8)).toDouble());
                break;

            case "14":
                airCompressorR1503.setMotorStatorTemperature(FloatOperate.operate(data.substring(0, 8)).toDouble());
                break;
            case "16":
                airCompressorR1503.setInboardMotorBearingTemperature(FloatOperate.operate(data.substring(0, 8)).toDouble());
                break;
            case "18":
                airCompressorR1503.setOutboardMotorBearingTemperature(FloatOperate.operate(data.substring(0, 8)).toDouble());
                break;
            case "1A":

                airCompressorR1503.setInletValve(FloatOperate.operate(data.substring(0, 8)).toDouble());
                airCompressorR1503.setUnloadingValve(FloatOperate.operate(data.substring(8, 16)).toDouble());

        }
//            case "22":
//                hex = data.substring(0, 4);
//                binary = StrUtil.hexStr2BinaryStr(hex);
//                binaries = binary.toCharArray();
//                airCompressorR1503.setAirFilterServiceAlarm(Character.digit(binaries[0], 2));
//                airCompressorR1503.setOilFilterServiceAlarm(Character.digit(binaries[1], 2));
//                airCompressorR1503.setOilSampleServiceAlarm(Character.digit(binaries[2], 2));
//                airCompressorR1503.setLubricantServiceAlarm(Character.digit(binaries[3], 2));
//                airCompressorR1503.setGreaseServiceAlarm(Character.digit(binaries[4], 2));
//                airCompressorR1503.setOilMistEliminatorServiceAlarm(Character.digit(binaries[5], 2));
//                airCompressorR1503.setCleanCoolerServiceAlarm(Character.digit(binaries[6], 2));
//                airCompressorR1503.setCleanAeroHardwareServiceAlarm(Character.digit(binaries[7], 2));
//                airCompressorR1503.setAirEndInspectionServiceAlarm(Character.digit(binaries[8], 2));
//                airCompressorR1503.setDriverOverhaulServiceAlarm(Character.digit(binaries[9], 2));
//                break;
//            case "24":
//                hex = data.substring(0, 4);
//                binary = StrUtil.hexStr2BinaryStr(hex);
//                binaries = binary.toCharArray();
//                airCompressorR1503.setMotorMContactor(Character.digit(binaries[0], 2));
//                airCompressorR1503.setAuxOilPump(Character.digit(binaries[1], 2));
//                airCompressorR1503.setCoolingWater(Character.digit(binaries[2], 2));
//                airCompressorR1503.setCommonAlarmRelay(Character.digit(binaries[3], 2));
//                airCompressorR1503.setCommonTripRelay(Character.digit(binaries[4], 2));
//                airCompressorR1503.setHorn(Character.digit(binaries[5], 2));
//                airCompressorR1503.setAlarmLight(Character.digit(binaries[6], 2));
//                airCompressorR1503.setTripLight(Character.digit(binaries[7], 2));
//                airCompressorR1503.setEmergencyStop(Character.digit(binaries[8], 2));
//                airCompressorR1503.setLowOilLevel(Character.digit(binaries[9], 2));
//                airCompressorR1503.setSealAirPressure(Character.digit(binaries[10], 2));
//                airCompressorR1503.setRemoteStart(Character.digit(binaries[11], 2));
//                airCompressorR1503.setRemoteStop(Character.digit(binaries[12], 2));
//                airCompressorR1503.setRemoteUnload(Character.digit(binaries[13], 2));
//                airCompressorR1503.setOilFilterDifPressure(Character.digit(binaries[14], 2));
//                airCompressorR1503.setAirFilterDifPressure(Character.digit(binaries[15], 2));
//            case "26":
//                hex = data.substring(0, 4);
//                airCompressorR1503.setD41301(StrUtil.hexStr2Int(hex));
//                break;
//            case "28":
//                hex = data.substring(0, 4);
//                airCompressorR1503.setD41322(StrUtil.hexStr2Int(hex));
//            case "3A":
//                hex = data.substring(0, 4);
//                airCompressorR1503.setD41343(StrUtil.hexStr2Int(hex));
//            //多字节
//            case "2C" : airCompressorR1503.setInletValve(FloatOperate.operate(data.substring(0, 8)).toDouble());
//                airCompressorR1503.setUnloadingValve(FloatOperate.operate(data.substring(8, 16)).toDouble());
//                airCompressorR1503.setInletValveManualMode(FloatOperate.operate(data.substring(16, 24)).toDouble());
//                airCompressorR1503.setUnloadingValveManualMode(FloatOperate.operate(data.substring(24, 32)).toDouble());
//                break;
//            case "34":
//                char[] binaries1 = StrUtil.hexStr2BinaryStr(data.substring(0, 4)).toCharArray();
//                char[] binaries2 = StrUtil.hexStr2BinaryStr(data.substring(4, 8)).toCharArray();
//                char[] binaries3 = StrUtil.hexStr2BinaryStr(data.substring(8, 12)).toCharArray();
//                char[] binaries4 = StrUtil.hexStr2BinaryStr(data.substring(12, 16)).toCharArray();
//                char[] binaries5 = StrUtil.hexStr2BinaryStr(data.substring(16, 20)).toCharArray();
//                char[] binaries6 = StrUtil.hexStr2BinaryStr(data.substring(20, 24)).toCharArray();
//                char[] binaries7 = StrUtil.hexStr2BinaryStr(data.substring(24, 28)).toCharArray();
//                char[] binaries8 = StrUtil.hexStr2BinaryStr(data.substring(28, 32)).toCharArray();
//                char[] binaries9 = StrUtil.hexStr2BinaryStr(data.substring(32, 36)).toCharArray();
//                char[] binaries10 = StrUtil.hexStr2BinaryStr(data.substring(36, 40)).toCharArray();
//
//                airCompressorR1503.setSptFailTrip(Character.digit(binaries1[0], 2));
//                airCompressorR1503.setSptLowAlarm(Character.digit(binaries1[1], 2));
//                airCompressorR1503.setSdtHighAlarm(Character.digit(binaries1[2], 2));
//                airCompressorR1503.setSdtLowTrip(Character.digit(binaries1[3], 2));
//                airCompressorR1503.setSdtHighTrip(Character.digit(binaries1[4], 2));
//                airCompressorR1503.setSdtBypassed(Character.digit(binaries1[5], 2));
//                airCompressorR1503.setSptFailAlarm(Character.digit(binaries1[6], 2));
//                airCompressorR1503.setDptFail(Character.digit(binaries1[8], 2));
//                airCompressorR1503.setDptLowAlarm(Character.digit(binaries1[9], 2));
//                airCompressorR1503.setDptHighAlarm(Character.digit(binaries1[10], 2));
//                airCompressorR1503.setDptLowTrip(Character.digit(binaries1[11], 2));
//                airCompressorR1503.setDptHighTrip(Character.digit(binaries1[12], 2));
//                airCompressorR1503.setDptBypassed(Character.digit(binaries1[13], 2));
//
//                airCompressorR1503.setOptFail(Character.digit(binaries2[0], 2));
//                airCompressorR1503.setOptLowAlarm(Character.digit(binaries2[1], 2));
//                airCompressorR1503.setOptHighAlarm(Character.digit(binaries2[2], 2));
//                airCompressorR1503.setOptLowTrip(Character.digit(binaries2[3], 2));
//                airCompressorR1503.setOptHighTrip(Character.digit(binaries2[4], 2));
//                airCompressorR1503.setOptBypassed(Character.digit(binaries2[5], 2));
//                airCompressorR1503.setMatFail(Character.digit(binaries2[8], 2));
//                airCompressorR1503.setMatLowAlarm(Character.digit(binaries2[9], 2));
//                airCompressorR1503.setMatHighAlarm(Character.digit(binaries2[10], 2));
//                airCompressorR1503.setMatLowTrip(Character.digit(binaries2[11], 2));
//                airCompressorR1503.setMatHighTrip(Character.digit(binaries2[12], 2));
//                airCompressorR1503.setMatBypassed(Character.digit(binaries2[13], 2));
//
//                airCompressorR1503.setLvtFail(Character.digit(binaries3[0], 2));
//                airCompressorR1503.setLvtLowAlarm(Character.digit(binaries3[1], 2));
//                airCompressorR1503.setLvtHighAlarm(Character.digit(binaries3[2], 2));
//                airCompressorR1503.setLvtLowTrip(Character.digit(binaries3[3], 2));
//                airCompressorR1503.setLvtHighTrip(Character.digit(binaries3[4], 2));
//                airCompressorR1503.setLvtBypassed(Character.digit(binaries3[5], 2));
//                airCompressorR1503.setHvtFail(Character.digit(binaries3[8], 2));
//                airCompressorR1503.setHvtLowAlarm(Character.digit(binaries3[9], 2));
//                airCompressorR1503.setHvtHighAlarm(Character.digit(binaries3[10], 2));
//                airCompressorR1503.setHvtLowTrip(Character.digit(binaries3[11], 2));
//                airCompressorR1503.setHvtHighTrip(Character.digit(binaries3[12], 2));
//                airCompressorR1503.setHvtBypassed(Character.digit(binaries3[13], 2));
//
//                airCompressorR1503.setIotFail(Character.digit(binaries4[0], 2));
//                airCompressorR1503.setIotLowAlarm(Character.digit(binaries4[1], 2));
//                airCompressorR1503.setIotHighAlarm(Character.digit(binaries4[2], 2));
//                airCompressorR1503.setIotLowTrip(Character.digit(binaries4[3], 2));
//                airCompressorR1503.setIotHighTrip(Character.digit(binaries4[4], 2));
//                airCompressorR1503.setIotBypassed(Character.digit(binaries4[5], 2));
//                airCompressorR1503.setIatFail(Character.digit(binaries4[8], 2));
//                airCompressorR1503.setIatLowAlarm(Character.digit(binaries4[9], 2));
//                airCompressorR1503.setIatHighAlarm(Character.digit(binaries4[10], 2));
//                airCompressorR1503.setIatLowTrip(Character.digit(binaries4[11], 2));
//                airCompressorR1503.setIatHighTrip(Character.digit(binaries4[12], 2));
//                airCompressorR1503.setIatBypassed(Character.digit(binaries4[13], 2));
//
//                airCompressorR1503.setActFail(Character.digit(binaries5[0], 2));
//                airCompressorR1503.setActLowAlarm(Character.digit(binaries5[1], 2));
//                airCompressorR1503.setActHighAlarm(Character.digit(binaries5[2], 2));
//                airCompressorR1503.setActLowTrip(Character.digit(binaries5[3], 2));
//                airCompressorR1503.setActHighTrip(Character.digit(binaries5[4], 2));
//                airCompressorR1503.setActBypassed(Character.digit(binaries5[5], 2));
//                airCompressorR1503.setFitFail(Character.digit(binaries5[8], 2));
//                airCompressorR1503.setFitLowAlarm(Character.digit(binaries5[9], 2));
//                airCompressorR1503.setFitHighAlarm(Character.digit(binaries5[10], 2));
//                airCompressorR1503.setFitLowTrip(Character.digit(binaries5[11], 2));
//                airCompressorR1503.setFitHighTrip(Character.digit(binaries5[12], 2));
//                airCompressorR1503.setFitBypassed(Character.digit(binaries5[13], 2));
//
//                airCompressorR1503.setFdtFail(Character.digit(binaries6[0], 2));
//                airCompressorR1503.setFdtLowAlarm(Character.digit(binaries6[1], 2));
//                airCompressorR1503.setFdtHighAlarm(Character.digit(binaries6[2], 2));
//                airCompressorR1503.setFdtLowTrip(Character.digit(binaries6[3], 2));
//                airCompressorR1503.setFdtHighTrip(Character.digit(binaries6[4], 2));
//                airCompressorR1503.setFdtBypassed(Character.digit(binaries6[5], 2));
//                airCompressorR1503.setSdtFail(Character.digit(binaries6[8], 2));
//                airCompressorR1503.setSdtLowAlarm(Character.digit(binaries6[9], 2));
//                airCompressorR1503.setSdtHighAlarm(Character.digit(binaries6[10], 2));
//                airCompressorR1503.setSdtLowTrip(Character.digit(binaries6[11], 2));
//                airCompressorR1503.setSdtHighTrip(Character.digit(binaries6[12], 2));
//                airCompressorR1503.setSdtBypassed(Character.digit(binaries6[13], 2));
//
//                airCompressorR1503.setSmtFail(Character.digit(binaries7[0], 2));
//                airCompressorR1503.setSmtLowAlarm(Character.digit(binaries7[1], 2));
//                airCompressorR1503.setSmtHighAlarm(Character.digit(binaries7[2], 2));
//                airCompressorR1503.setSmtLowTrip(Character.digit(binaries7[3], 2));
//                airCompressorR1503.setSmtHighTrip(Character.digit(binaries7[4], 2));
//                airCompressorR1503.setSmtBypassed(Character.digit(binaries7[5], 2));
//                airCompressorR1503.setImtFail(Character.digit(binaries7[8], 2));
//                airCompressorR1503.setImtLowAlarm(Character.digit(binaries7[9], 2));
//                airCompressorR1503.setImtHighAlarm(Character.digit(binaries7[10], 2));
//                airCompressorR1503.setImtLowTrip(Character.digit(binaries7[11], 2));
//                airCompressorR1503.setImtHighTrip(Character.digit(binaries7[12], 2));
//                airCompressorR1503.setImtBypassed(Character.digit(binaries7[13], 2));
//
//                airCompressorR1503.setOmtFail(Character.digit(binaries8[0], 2));
//                airCompressorR1503.setOmtLowAlarm(Character.digit(binaries8[1], 2));
//                airCompressorR1503.setOmtHighAlarm(Character.digit(binaries8[2], 2));
//                airCompressorR1503.setOmtLowTrip(Character.digit(binaries8[3], 2));
//                airCompressorR1503.setOmtHighTrip(Character.digit(binaries8[4], 2));
//                airCompressorR1503.setOmtBypassed(Character.digit(binaries8[5], 2));
//                airCompressorR1503.setHvt2Fail(Character.digit(binaries8[8], 2));
//                airCompressorR1503.setHvt2LowAlarm(Character.digit(binaries8[9], 2));
//                airCompressorR1503.setHvt2HighAlarm(Character.digit(binaries8[10], 2));
//                airCompressorR1503.setHvt2LowTrip(Character.digit(binaries8[11], 2));
//                airCompressorR1503.setHvt2HighTrip(Character.digit(binaries8[12], 2));
//                airCompressorR1503.setHvt2Bypassed(Character.digit(binaries8[13], 2));
//
//                airCompressorR1503.setEstopTrip(Character.digit(binaries9[0], 2));
//                airCompressorR1503.setMotorFailureTrip(Character.digit(binaries9[1], 2));
//                airCompressorR1503.setOilPumpTrip(Character.digit(binaries9[2], 2));
//                airCompressorR1503.setCondenstateLevelTrip(Character.digit(binaries9[4], 2));
//
//                airCompressorR1503.setSurgeAlarm(Character.digit(binaries10[0], 2));
//                airCompressorR1503.setSapsAlarm(Character.digit(binaries10[1], 2));
//                airCompressorR1503.setLolsAlrm(Character.digit(binaries10[2], 2));
//                airCompressorR1503.setOfdpAlarm(Character.digit(binaries10[3], 2));
//                airCompressorR1503.setAfdpAlarm(Character.digit(binaries10[4], 2));
//                airCompressorR1503.setChannelBypassedAlarm(Character.digit(binaries10[5], 2));
//                airCompressorR1503.setCondensationLevelAlarm(Character.digit(binaries10[6], 2));
//                airCompressorR1503.setServiceAlarm(Character.digit(binaries10[7], 2));
//                break;
//
//            case "36":
//                airCompressorR1503.setRuntime(StrUtil.hexStr2Int(data.substring(0, 8)));
//                airCompressorR1503.setNumberOfStarts(StrUtil.hexStr2Int(data.substring(8, 16)));
//                airCompressorR1503.setNumberOfSurges(StrUtil.hexStr2Int(data.substring(16, 24)));
//                airCompressorR1503.setPoweronTime(StrUtil.hexStr2Int(data.substring(24, 32)));
//                break;
//
//            case "40":
//                airCompressorR1503.setRuntime(StrUtil.hexStr2Int(data.substring(0, 8)));
//                airCompressorR1503.setAirFilterServiceTime(StrUtil.hexStr2Int(data.substring(0, 8)));
//                airCompressorR1503.setOilFilterServiceTime(StrUtil.hexStr2Int(data.substring(0, 8)));
//                airCompressorR1503.setOilSampleServiceTime(StrUtil.hexStr2Int(data.substring(0, 8)));
//                airCompressorR1503.setLubricantServiceTime(StrUtil.hexStr2Int(data.substring(0, 8)));
//                airCompressorR1503.setGreaseServiceTime(StrUtil.hexStr2Int(data.substring(0, 8)));
//                airCompressorR1503.setOilMistEliminatorServiceTime(StrUtil.hexStr2Int(data.substring(0, 8)));
//                airCompressorR1503.setCleanCoolerServiceTime(StrUtil.hexStr2Int(data.substring(0, 8)));
//                airCompressorR1503.setCleanAeroHardwareServiceTime(StrUtil.hexStr2Int(data.substring(0, 8)));
//                airCompressorR1503.setAirEndInspectionServiceTime(StrUtil.hexStr2Int(data.substring(0, 8)));
//                airCompressorR1503.setDriverOverhaulServiceTime(StrUtil.hexStr2Int(data.substring(0, 8)));
//        }
//        DataCollectingApplication.ampsHis.put(ip, Float.parseFloat(airCompressorR1503.getMotorAmps().toString()));
//        DataCollectingApplication.powerHis.put(ip, (airCompressorR1503.getMotorAmps() * 14.9425 / 12 ));
        return airCompressorR1503;
    }

    @Override
    public IService getService() {
        return service;
    }
}
